<template>
	<div class="btn-box">
		<el-button :disabled="disabled" @click="toSearch" class="btn" size="large">查询</el-button>
		<br />
		<el-button :disabled="disabled" @click="toApplyFor" class="btn" size="large" type="success">申请</el-button>
	</div>
</template>

<script setup lang="ts">
	import { useRoute, useRouter } from 'vue-router'
	import { onMounted, ref } from 'vue'
	import { DepositInit } from '@/api/apis.ts'
	import { ElMessage } from 'element-plus'

	const router = useRouter()
	const disabled = ref(true)
	const route = useRoute()
	const init = async () => {
		console.log(route.query)
		const query = route.query
		const res = await DepositInit(query.sign, query.token, query.timestamp)
		console.log(res)
		if (res.data.code == 200) {
			disabled.value = false
		} else {
			ElMessage({
				type: 'error',
				message: res.data.message,
			})
		}
	}

	onMounted(() => {
		init()
	})

	const toSearch = () => {
		router.push('search')
	}
	const toApplyFor = () => {
		router.push('applyFor')
	}
</script>

<style scoped lang="scss">
	.btn-box {
		width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		.btn {
			width: 300px;
			height: 50px;
		}
	}
</style>
